#ifndef FLOWVIEW_H
#define FLOWVIEW_H
#include <QFrame>

class FlowView : public QFrame
{
    Q_OBJECT

public:
    explicit FlowView(QWidget* parent = nullptr);

    void setSpacing(int spacing);
    void setUseSizeHint(bool use);
    bool empty() const { return items_.empty(); }
    const QList<QWidget*>& items() const { return items_; }
    QWidget* itemAt(const QPoint& mpos) const;
    void addItem(QWidget* item);
    void addItems(const QList<QWidget*>& items);
    void setItems(const QList<QWidget*>& items, int from = 0);
    void takeItems(const QList<QWidget*>& items);
    void removeItem(QWidget* item);
    void removeItems(int from);
    void layoutItems();
    void clear();

    int heightForWidth(int w) const override;
    bool hasHeightForWidth() const override { return true; }

protected:
    void resizeEvent(QResizeEvent* re) override;

private:
    int spacing_ = 6;
    bool use_size_hint_ = true;
    QList<QWidget*> items_;
};

#endif // FLOWVIEW_H
